/**
 * Created by steven on 2016/4/22.
 */
$("#showTooltips").on('click',function(){
    var q_type=$('#q_type').val();
    var q_content=$('#q_content').val();
    var q_title=$('#q_title').val();
    var support=$('#supportorId').html();
    if(q_type==''){
        $('#dialog_info').html("您还没有选择类别");
        $('#weui_dialog_alert').show();
        return;
    }
    if(q_title.length<4 || q_title.length>100 ){
        $('#dialog_info').html("咨询标题应该在4~100个字符之间！");
        $('#weui_dialog_alert').show();
        return;
    }
    if(q_content.length<8 ||q_content.length>5000){
        $('#dialog_info').html("咨询内容应该大于8个字且小于5000个字！");
        $('#weui_dialog_alert').show();
        return;
    }
    var url='http://www.fddiaoyu.com/index.php/law_help/save_q';
    var dt={
        q_type:q_type,
        q_content:q_content,
        q_title:q_title,
        support:support
    };
    var aj = $.ajax( {
        url:url,// 跳转到 action
        data:dt,
        type:'post',
        cache:false,
        dataType:'json',
        success:function(data) {
           var isSuccess=data.isSuccess;
            if(!isSuccess){
                giveAlert(data.errorMessage);
            }else{
                location.href = "index.php/law_help/q/detail/"+data.data.question_id;
            }
          },
        error : function(XMLHttpRequest, textStatus, errorThrown) {
            //alert(XMLHttpRequest.status);
            //alert(XMLHttpRequest.readyState);
            //alert(textStatus);
        }
     });
});

$("#dialog_check").on('click',function(){
    $('#weui_dialog_alert').hide();
});

function giveAlert(message){
    $('#dialog_info').html(message)
    $('#weui_dialog_alert').show();
}
